package com.kingdee.pda.ui.check_order;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.kingdee.pda.R;
import com.kingdee.pda.adapter.AbsBaseAdapter;
import com.kingdee.pda.entity.CheckOrderListBean;
import com.kingdee.pda.util.ViewHolder;

public class CheckOrderListAdapter extends AbsBaseAdapter<CheckOrderListBean> {

    public CheckOrderListAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {


        if (convertView == null) {
            convertView = inflater.inflate(R.layout.adapter_item_check_order_list, parent, false);
        }

        TextView tv_orderNo = ViewHolder.get(convertView, R.id.tv_orderNo);
        TextView tv_order_status = ViewHolder.get(convertView, R.id.tv_order_status);
        TextView tv_check_type = ViewHolder.get(convertView, R.id.tv_check_type);
        TextView tv_time = ViewHolder.get(convertView, R.id.tv_time);
        Button  checkOrder = ViewHolder.get(convertView, R.id.btn_start_check_order);

        CheckOrderListBean orderData = getData().get(position);
        tv_orderNo.setText(orderData.billno);
        tv_order_status.setText("盘点状态: "+transOrderStatus(orderData.billstatus));
        tv_check_type.setText(orderData.inventorytype);
        tv_time.setText(orderData.createtime);
        checkOrder.setOnClickListener(v -> {
                    Intent i = new Intent(context,CheckOrderDetailActivity.class);
                    i.putExtra("bilno",orderData.billno);
                    i.putExtra("bilstatus",orderData.billstatus);
                    context.startActivity(i);
        });



        return convertView;
    }

    private String transOrderStatus(String billStaus){
        String t = "";
        if (TextUtils.equals(billStaus,"3"))  {
            t = "待初盘";
        } else if (TextUtils.equals(billStaus, "5")) {
            t = "待复盘";
        }
        return t ;
    }

}
